package com.example.demo.service;

import com.example.demo.mapper.DepartmentMapper;
import com.example.demo.pojo.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class DepartmentService {
    @Autowired
    private DepartmentMapper departmentDao;
    /**
     * 获取所有部门
     * @return 所有部门
     */
    public List<Department> getAllTheDepartments(){
        return departmentDao.selectAll();
    }

    public void addNewDepartment(Department department){
        departmentDao.addDepartment(department);
    }


    public void deleteDepartmentById(int id){
        departmentDao.deleteDepartmentById(id);
    }

    public Department getDepartmentById(Integer id) {
        return departmentDao.selectDepartmentById(id);
    }

    public void updateDepartment(Department department) {
        departmentDao.updateDepartment(department);
    }
}
